package itheima.zuoye.Test3;

import java.util.HashSet;
import java.util.TreeSet;

public class test {
    public static void main(String[] args) {
        //方式一，使用HashSet对10个学生进行去重

        HashSet<Student> students = new HashSet<>();
        students.add(new Student("张伟", 22));
        students.add(new Student("张伟", 22));
        students.add(new Student("王芳", 19));
        students.add(new Student("刘洋", 25));
        students.add(new Student("赵敏", 21));
        students.add(new Student("陈静", 23));
        students.add(new Student("陈静", 23));
        students.add(new Student("黄军", 18));
        students.add(new Student("周洋", 26));
        students.add(new Student("周洋", 26));

        // 输出结果
        System.out.println("集合中的学生信息数量: " + students.size());
        System.out.println("集合中的学生信息:");
        students.forEach(System.out::println);


        //方式二使用TreeSet对10个学生进行去重
        TreeSet<Student> student = new TreeSet<>();
        student.add(new Student("周杰伦", 18));
        student.add(new Student("周杰伦", 18));
        student.add(new Student("周杰伦", 18));
        student.add(new Student("周杰伦", 18));
        student.add(new Student("周杰伦", 18));
        student.add(new Student("周杰伦", 18));
        student.add(new Student("周杰伦", 18));
        student.add(new Student("周杰伦", 18));
        student.add(new Student("赵敏", 21));
        student.add(new Student("陈静", 23));
        student.add(new Student("陈静", 23));
        student.add(new Student("黄军", 18));

        System.out.println("集合中的学生信息数量: " + student.size());
        System.out.println("集合中的学生信息:");
        student.forEach(System.out::println);






    }
}
